package hu.stud.uszeged.inf.prf.prftrac.session.controllers;

import hu.stud.uszeged.inf.prf.prftrac.entity.Event;
import hu.stud.uszeged.inf.prf.prftrac.entity.Ticket;
import hu.stud.uszeged.inf.prf.prftrac.session.dao.EventDao;
import hu.stud.uszeged.inf.prf.prftrac.session.dao.TicketDao;

import java.util.Date;
import java.util.GregorianCalendar;
import java.util.LinkedList;
import java.util.List;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Scope(ScopeType.EVENT)
@Name("timelineController")
public class TimelineController {

	@In("#{eventDao}")
	private EventDao eventDao;
	@In("#{ticketDao}")
	private TicketDao ticketDao;
	
	public List<Event> getEventsOrderedByDate() {
		return eventDao.getEventsOrderedByDate();
	}
	
	public List<Event> getEventsByDate(Date d) {
		return eventDao.getEventsByDate(d);
	}
	
	public List<Date> getDistinctDates() {
		return eventDao.getDistinctDates();
//		List<Date> dates = eventDao.getDistinctDates();
//		List<Date> ret = new LinkedList<Date>();
//		ret.add(dates.get(0));
//		for (Date d : dates) {
//			for (Date q : dates) {
//				if (d == q) continue;
//				if ((d.getYear() != q.getYear() || d.getMonth() != q.getMonth() || d.getDate() != q.getDate()) && !ret.contains(q)) {
//					ret.add(q);
//				}
//			}
//		}
//		return ret;
	}
	
	public Ticket getTicketById(Long id) {
		return ticketDao.getTicket(id);
	}
}
